package com.answer.config;

import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.utils.Constants;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "ai")
@Data
public class AiConfig {

    /**
     * apiKey，需要从开放平台获取
     */
    private String apiKey;

    /**
     * 获取Generation实例
     *
     * @return Generation 实例
     * 初始化Generation实例时，将当前对象的apiKey属性值赋值给Constants的apiKey静态变量
     * 这样做是为了确保在Generation类中可以访问到API密钥，以便在生成操作中使用
     */
    public Generation getGeneration() {
        Constants.apiKey = apiKey;
        return new Generation();
    }
}
